﻿import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
    width: screenWidth
    height: 120

    Item{
        id:backGround
        anchors.fill: parent
    }

    property real currentPanel: 1

    Row{
        spacing: 2
        Repeater{
            model: 7
            Rectangle{
                width: 153
                height: 120
                radius: 10
                color: index === currentPanel ? "gold" :"#3085f6"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: 30
                    font.bold: true
                    color: "white"
                    text:{index === 0 ? "首页":
                          index === 1 ? "自动加工":
                          index === 2 ? "手动操作":
                          index === 3 ? "配方设定":
                          index === 4 ? "输入输出":
                          index === 5 ? "报警界面":
                                        "设置界面"}
                }

                MouseArea{
                    anchors.fill: parent

                    onClicked: {
                        currentPanel = index
                        // console.log(currentPanel)
                        if(currentPanel === 0)
                        {
                            loginWindow.visible = true
                            automaticPanel.visible = false
                            singleReturnPanel.visible = false
                            manualPanel.visible = false
                            formulaPanel.visible = false
                            ioPanel.visible = false
                            warningMassagePanel.visible = false
                            warningCorePanel.visible = false
                            parameterSettingPanel.visible = false
                            commonSettingPanel.visible = false
                            standbySettingPanel.visible = false
                            originSettingPanel.visible = false
                            limitSettingPanel.visible = false
                            compensateSettingPanel.visible = false
                            zeroSettingPanel.visible  = false

                        }
                        else if(currentPanel === 1)
                        {
                            loginWindow.visible = false
                            automaticPanel.visible = true
                            singleReturnPanel.visible = false
                            manualPanel.visible = false
                            formulaPanel.visible = false
                            ioPanel.visible = false
                            warningMassagePanel.visible = false
                            warningCorePanel.visible = false
                            parameterSettingPanel.visible = false
                            commonSettingPanel.visible = false
                            standbySettingPanel.visible = false
                            originSettingPanel.visible = false
                            limitSettingPanel.visible = false
                            compensateSettingPanel.visible = false
                            zeroSettingPanel.visible  = false

                            // 刷新数据
                            Cpp_Qmlengine.qmlRefreshModelData();
                            automaticPanel.selectIndex = -1
                            Cpp_Connect.setQmlPage(1);
                        }
                        else if(currentPanel === 2)
                        {
                            loginWindow.visible = false
                            automaticPanel.visible = false
                            singleReturnPanel.visible = false
                            manualPanel.visible = true
                            formulaPanel.visible = false
                            ioPanel.visible = false
                            warningMassagePanel.visible = false
                            warningCorePanel.visible = false
                            parameterSettingPanel.visible = false
                            commonSettingPanel.visible = false
                            standbySettingPanel.visible = false
                            originSettingPanel.visible = false
                            limitSettingPanel.visible = false
                            compensateSettingPanel.visible = false
                            zeroSettingPanel.visible  = false

                            Cpp_Connect.setQmlPage(3);
                        }
                        else if(currentPanel === 3)
                        {
                            loginWindow.visible = false
                            automaticPanel.visible = false
                            singleReturnPanel.visible = false
                            manualPanel.visible = false
                            formulaPanel.visible = true
                            ioPanel.visible = false
                            warningMassagePanel.visible = false
                            warningCorePanel.visible = false
                            parameterSettingPanel.visible = false
                            commonSettingPanel.visible = false
                            standbySettingPanel.visible = false
                            originSettingPanel.visible = false
                            limitSettingPanel.visible = false
                            compensateSettingPanel.visible = false
                            zeroSettingPanel.visible  = false

                            // 刷新数据
                            Cpp_Qmlengine.qmlRefreshModelData();

                            Cpp_Connect.setQmlPage(4);
                        }
                        else if(currentPanel === 4)
                        {
                            loginWindow.visible = false
                            automaticPanel.visible = false
                            singleReturnPanel.visible = false
                            manualPanel.visible = false
                            formulaPanel.visible = false
                            ioPanel.visible = true
                            warningMassagePanel.visible = false
                            warningCorePanel.visible = false
                            parameterSettingPanel.visible = false
                            commonSettingPanel.visible = false
                            standbySettingPanel.visible = false
                            originSettingPanel.visible = false
                            limitSettingPanel.visible = false
                            compensateSettingPanel.visible = false
                            zeroSettingPanel.visible  = false

                            Cpp_Connect.setQmlPage(5);
                        }
                        else if(currentPanel === 5)
                        {
                            loginWindow.visible = false
                            automaticPanel.visible = false
                            singleReturnPanel.visible = false
                            manualPanel.visible = false
                            formulaPanel.visible = false
                            ioPanel.visible = false
                            warningMassagePanel.visible = true
                            warningCorePanel.visible = false
                            parameterSettingPanel.visible = false
                            commonSettingPanel.visible = false
                            standbySettingPanel.visible = false
                            originSettingPanel.visible = false
                            limitSettingPanel.visible = false
                            compensateSettingPanel.visible = false
                            zeroSettingPanel.visible  = false

                            Cpp_Connect.setQmlPage(6);
                        }
                        else if(currentPanel === 6)
                        {
                            loginWindow.visible = false
                            automaticPanel.visible = false
                            singleReturnPanel.visible = false
                            manualPanel.visible = false
                            formulaPanel.visible = false
                            ioPanel.visible = false
                            warningMassagePanel.visible = false
                            warningCorePanel.visible = false
                            parameterSettingPanel.visible = true

                            if(parameterSettingPanel.bottomSwitchBtnEnabled)
                            {
                                parameterSettingPanel.visible = false
                                parameterSettingPanel.currentPanel = 0
                                topShowArea.test = "常用参数设置"
                                commonSettingPanel.visible = true
                                standbySettingPanel.visible = false
                                originSettingPanel.visible = false
                                limitSettingPanel.visible = false
                                compensateSettingPanel.visible = false
                                zeroSettingPanel.visible  = false

                                Cpp_Connect.setQmlPage(8);
                            }                          
                        }
                    }
                }
            }
        }
    }

}
